package game.telemetry
{
	import engine.core.*;
	import flash.events.*;
	import flash.net.*;
	
	public class RxPlatform
	{
		private static var s_platformUrl:String;
		private static var s_gameId:String;
		
		public function RxPlatform()
		{
		}
		
		public static function Initialize(platformUrl:String, gameId:String) : void
		{
			s_platformUrl = platformUrl;
			s_gameId = gameId;
		}
		
		public static function NoteEvent(param1:String, param2:Object) : void
		{
			var _loc_3:String = null;
			_loc_3 = JSON.stringify(param2);
			RxLog.Info("RxPlatform.NoteEvent(): " + param1 + ": " + _loc_3);
			var _loc_4:* = Base64.encode(_loc_3);
			var _loc_5:* = new URLVariables();
			_loc_5.ts = -1;
			_loc_5.event = param1;
			_loc_5.data = _loc_4;
			_loc_5.game = s_gameId;
			Request("rapiEvent/noteEvent", _loc_5);
		}
		
		public static function Request(param1:String, param2:URLVariables) : void
		{
			if (s_platformUrl == null || s_gameId == null)
			{
				RxLog.Error("request attempted on uninitialized platform");
	
			}
			var _loc_3:* = s_platformUrl + param1;
			RxLog.Info("RxPlatform.Request(): " + _loc_3 + "?" + param2);
			var _loc_4:* = new URLLoader();
			var _loc_5:* = new URLRequest(_loc_3);
			RxLog.Trace(_loc_3 + param2);
			_loc_5.method = URLRequestMethod.POST;
			_loc_5.data = param2;
			_loc_4.addEventListener(Event.COMPLETE, OnComplete);
			_loc_4.addEventListener(IOErrorEvent.IO_ERROR, OnIOError);
			_loc_4.addEventListener(SecurityErrorEvent.SECURITY_ERROR, OnSecurityError);
			_loc_4.addEventListener(HTTPStatusEvent.HTTP_STATUS, OnHTTPStatus);
			_loc_4.load(_loc_5);
		}
		
		private static function OnHTTPStatus(event:HTTPStatusEvent) : void
		{

		}
		
		private static function OnComplete(event:Event) : void
		{
			RxLog.Trace("RxPlatform.OnComplete()");
			var _loc_2:* = URLLoader(event.target);
			var _loc_3:* = _loc_2.bytesLoaded;
			var _loc_4:* = _loc_2.data;

		}
		
		private static function OnIOError(event:IOErrorEvent) : void
		{
			RxLog.Info("RxPlatform.OnIOError()");

		}
		
		private static function OnSecurityError(event:SecurityErrorEvent) : void
		{
			RxLog.Info("RxPlatform.OnSecurityError()");

		}
	}
}